<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = []
        let age
        let sum = 0
       
        for (let i = 1; i <= 5; i++) {
            let age = +prompt(`请输入第${i}个有效年龄(0~100)`)
            if (age >= 0 && age <= 100) {
                arr.push(age)
            }
            else {
                alert('您的输入有误请重新输入')
                i--
            }
        }
        alert(arr)
        let max = arr[0]
        let min = arr[0]
        for (let j = 0; j < arr.length; j++) {
            sum += arr[j]
            if (max < arr[j + 1]) {
                max = arr[j + 1]
            }
            if (min > arr[j + 1]) {
                min = arr[j + 1]
            }
        }
        let re = sum / 5
        arr.sort()
        document.write(`年龄排序是${arr}</br>`)
        document.write(`五个人的总年龄是${sum}</br>`)
        document.write(`五个人的平均年龄是${re}</br>`)
        document.write(`五个人的最大年龄是${max}</br>`)
        document.write(`五个人的最小年龄是${min}</br>`)
    </script>
</body>

</html>